<template>
  <view class="nav-box" :style="{marginTop:barHeight,background:bgColor}"
    >
    <view class="nav-content">
      <view class="nav-top-one">
        <img
          src="https://szgd-dev.tgovcloud.com/public/images/arr-left.png"
          class="nav-top-left"
          @click="btnClick"
        >
      </view>
      <view class="nav-top-text" :style="{color:titleColor}">{{ title }}</view>
    </view>
  </view>
</template>
<script>
export default {
    props: ["title","bgColor","titleColor"],
    data(){
        return {
            barHeight:'',
        }
    },
    onReady() {
        this.getbarHeight();
    },
    methods:{
        btnClick() {
            this.$emit("btnClick");
        },
        //获取高度
        getbarHeight() { 
            uni.getSystemInfo({
                success: (res) => {
                    this.barHeight = `${res.statusBarHeight}px`;
                },
            });
        },
    }
}
</script>
<style scoped lang="scss">
.nav-box {
  position: fixed;
  top: 0;
  width: 100%;
  height: 76rpx;
  z-index: 99;
}
.nav-content{
  display: flex;
  align-items: center;
  position: relative;
  height: 100%;
  .nav-top-one {
    padding: 0 26rpx;
    display: flex;
    align-items: center;
    .nav-top-left {
      height: 40rpx;
      width: 35rpx;
    }
  }
  .nav-top-text {
    position: absolute;
    width: 40%;
    left: 50%;
    top: 50%;
    transform:translate(-50%,-50%);
    font-size: 38rpx;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    height: 52rpx;
    line-height: 52rpx;
    text-align: center;
    overflow: hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }
}
</style>